import HTTP from '../utils/http';
import { API } from '../config/config';
import { Message } from 'element-ui';
import { axiosMessageShow } from '@/utils/tools';

const LOGIN = API.LOGIN;

export default class LoginService extends HTTP {
    
    loginLogout() {
        return new Promise((resolve) => {
            this.axiosGet({
                url: LOGIN.LOGIN_OUT,
                success(data) {
                    axiosMessageShow(data);
                    resolve(data);
                }, error(error) {
                    Message({
                        message: error,
                        type: 'error'
                    })
                }
            })
        })
    }
    loginAction(userInfo) {
        return new Promise((resolve) => {
            this.axiosPost({
                url: LOGIN.LOGIN_ACTION,
                data: userInfo,
                success(data) {
                    axiosMessageShow(data);
                    resolve(data)
                },
                error(error) {
                    Message({
                        message: error,
                        type: 'error'
                    })

                }
            })
        })
    }
    loginUpdate(password) {
        return new Promise((resolve) => {
            this.axiosPost({
                url: LOGIN.LOGIN_UPDATE,
                data: password,
                success(data) {
                    axiosMessageShow(data);
                    resolve(data)
                },
                error(error) {
                    Message({
                        message: error,
                        type: 'error'
                    })

                }
            })
        })
    }

}   